<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>箭头函数</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
    <div id="app">
    </div>

    <script>
        const traditionalFunction=function(message){
            console.log(message);
        }
        const arrowFunction=message=>console.log(message);
        traditionalFunction("This is traditionalFunction");
        arrowFunction("This is arrow Function");

        function ThisInTraditionalFunction(){
            this.name="Traditional";
            setTimeout(function(){
                console.log(this.name);
            },10);
        }
        function ThisInArrowFunction(){
            this.name="Arrow";
            setTimeout(()=>{
                console.log(this.name);
            },200);
        }
        function greet(name="World"){
            return `Hello,${name}!`;
        }

        ThisInTraditionalFunction();
        ThisInArrowFunction();
        console.log(greet());
        console.log(greet('Vue3'));
    </script>
</body>
</html>
